﻿#region Copyright(C) 2018 FI Ltd. All rights reserved.
// ==================================================================================================
// Copyright(C) 2018 FI Ltd. All rights reserved.
//
// SYSTEM NAME      : FI.Net Application Framework
// COMPONENT ID     : ApplicationContext
// COMPONENT DESC   : Session based contextual data sharing.
//
// CREATED DATE/BY  : 18 Aug 2018 / Tian Mi
//
// REVISION HISTORY :
// DATE/BY            SR#/CS/PM#/OTHERS      DESCRIPTION OF CHANGE
// ==================================================================================================
#endregion

using FI.Core.Utilities;
using System.Runtime.Serialization;
using System.Threading;

namespace FI.Core.ApplicationContexts
{
    /// <summary>
    /// This class holds context items and thread information cloned from current application context.
    /// </summary>
    [DataContract(Namespace=Constants.Namespace)]
    public class DependentApplicationContext
    {
        /// <summary>
        /// Gets the collection of context items.
        /// </summary>
        /// <value>
        /// The collection of context items.
        /// </value>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists")]
        [DataMember]
        public ContextItemCollection Items { get; private set; }

        /// <summary>
        /// Gets the master thread to which the current application is belong.
        /// </summary>
        /// <value>
        /// The master thread to which the current application is belong.
        /// </value>
        public Thread MasterThread { get; private set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="DependentApplicationContext"/> class.
        /// </summary>
        /// <param name="items">The collection of context items.</param>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists")]
        public DependentApplicationContext(ContextItemCollection items)
        {
            Guard.ArgumentNotNull(items, "items");
            this.Items = items;
            this.MasterThread = Thread.CurrentThread;
        }
    }
}
